package main

import (
	"fmt"
	"unsafe"
)

const (
	x       = 1 << iota //x= 1<<0   =1
	y       = 3 << iota // y=3<<1   =6
	z                   // z=3<<2   =12
	z1                  // z1=3<<3  =24
	a1      = "abc"
	b1      = len(a1)
	c1      = unsafe.Sizeof(a1)
	Unknown = 0
	Female  = 1
	Male    = 2
)

func main() {
	const (
		a  = iota //0
		aa = iota //1
		b         //2
		c         //3
		d  = "ha" //独立值，iota += 1
		e         //"ha"   iota += 1
		f  = 100  //iota +=1
		g         //100  iota +=1
		h  = iota //8,恢复计数
		i         //9
	)
	fmt.Println(a, aa, b, c, d, e, f, g, h, i)
	fmt.Println(x, y, z, z1)
	println(a1, b1, c1, Unknown, Female, Male)

	var num1 uint = 60 /* 60 = 0011 1100 */
	var num2 uint = 13 /* 13 = 0000 1101 */
	var num3 uint = 0
	num3 = num1 & num2 /* 12 = 0000 1100 */
	fmt.Printf("第一行 - c 的值为 %d\n", num3)
	num3 = num1 | num2
	fmt.Printf("第二行 - c 的值为 %d\n", num3)
	num3 = num1 ^ num2
	fmt.Printf("第三行 - c 的值为 %d\n", num3)
	num3 = num1 << 2
	fmt.Printf("第四行 - c 的值为 %d\n", num3)
	num3 = num1 >> 2
	fmt.Printf("第五行 - c 的值为 %d\n", num3)

	var num4 int = 4
	var ptr *int
	fmt.Printf("num4 为 %d\n", num4)
	ptr = &num4
	fmt.Printf("*ptr 为 %d\n", *ptr)
	var ptr1 *int = new(int)
	*ptr1 = 10
	fmt.Printf("*ptr1 为 %d\n", *ptr1)

}
